package com.financing.wap.dao.impl;

import java.sql.SQLException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.financing.wap.common.Pager;
import com.financing.wap.common.SqlName;
import com.financing.wap.dao.IProjectLikeDao;
import com.financing.wap.dto.ProjectLikeDTO;
import com.financing.wap.vo.ProjectLikeVO;
import com.financing.wap.vo.ProjectSubVO;

@Repository("projectLikeDaoImpl")
@SuppressWarnings(value={"deprecation","unchecked"})
public class ProjectLikeDaoImpl extends BaseDaoImpl<ProjectLikeDTO, java.lang.Integer> implements IProjectLikeDao {

	@Override
	public List<ProjectLikeVO> projectLikeList(Map<String,Object> map)
			throws SQLException {
		return this.sqlMapClientTemplate.queryForList(SqlName.queryProjectLike, map);
	}

	@Override
	public int addProjectLike(ProjectLikeDTO projectLikeDTO)
			throws SQLException {
		return (Integer) this.sqlMapClientTemplate.insert(SqlName.addProjectLike, projectLikeDTO);
	}

	@Override
	public int deleteProjectLike(ProjectLikeDTO projectLikeDTO)
			throws SQLException {
		return this.sqlMapClientTemplate.delete(SqlName.deleteProjectLike, projectLikeDTO);
	}

	@Override
	public Class<ProjectLikeDTO> getEntityClass() {
		return ProjectLikeDTO.class;
	}

	@Override
	public int countProjectLike(Integer porjectId) {
		return (Integer) this.sqlMapClientTemplate.queryForObject(SqlName.COUNT_PROJECT_LIKE,porjectId);
	}

	@Override
	public int countProjectLikeForFa(ProjectLikeDTO projectLikeDTO) {
		return (Integer) this.sqlMapClientTemplate.queryForObject(SqlName.COUNT_PROJECT_LIKE_FOR_FA,projectLikeDTO);
	}
	
	@Override
	public int countProjectLikepType(Map<String, Object> map) {
		return (Integer) this.sqlMapClientTemplate.queryForObject(SqlName.COUNT_PROJECT_LIKE_PTYPE,map);
	}

	@Override
	public List<ProjectLikeDTO> queryProjectLikeType(Map<String, Object> map) {
		  
		   return   this.sqlMapClientTemplate.queryForList(SqlName.PROJECT_LIKE_LIKE_TYPE,map);
	}

	@Override
	public List<ProjectSubVO> queryProjectFlow(Map<String, Object> param) {
		return this.sqlMapClientTemplate.queryForList(SqlName.queryProjectFlow, param);
	}

	@Override
	public Integer querySubTimesBypId(Integer pId) {
		return (Integer) this.sqlMapClientTemplate.queryForObject(SqlName.COUNT_PROJECT_SUB,pId);
	}

	@Override
	public List<ProjectLikeVO> queryProjectSubForFa(String uId) {
		return this.sqlMapClientTemplate.queryForList(SqlName.queryProjectSubByuId, uId);
	}

	@Override
	public int countProjectFlow(Integer pId) {
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("pId", pId);
		return (Integer) this.sqlMapClientTemplate.queryForObject(SqlName.countProjectFlow,param);
	}

	@Override
	public Date getPrijectLikeUpdateDateByFa(Map<String, Object> param) throws SQLException {
		return (Date) this.sqlMapClientTemplate.queryForObject(SqlName.getPrijectLikeUpdateDateByFa,param);
	}
}
